﻿<Window x:Class="wUniApp.WPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:wUniApp.WPF.Controls"
        xmlns:loc="clr-namespace:wUniAppPCL.Loacalization;assembly=wUniAppPCL"
        Title="MainWindow" Height="600" Width="800">
  <Window.Resources>
    <loc:wLocProvider x:Key="wLoc"/>
    <Style TargetType="TabControl">
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="BorderBrush" Value="Transparent"/>
    </Style>
    <Style TargetType="TabItem">
      <Setter Property="Foreground" Value="White" />
      <Setter Property="VerticalAlignment" Value="Top" />
      <Setter Property="FontSize" Value="18" />
      <Setter Property="Background" Value="Transparent"/>
      <Style.Triggers>
        <Trigger Property="IsSelected" Value="True">
          <Setter Property="Foreground" Value="SteelBlue"/>
          <Setter Property="Background" Value="White"/>
        </Trigger>
        <Trigger Property="IsSelected" Value="False">
          <Setter Property="Foreground" Value="LightGray"/>
          <Setter Property="Background" Value="#30000000"/>
        </Trigger>
      </Style.Triggers>
    </Style>
  </Window.Resources>
  <Grid>
    <Grid.Background>
        <ImageBrush ImageSource="Assets/background.jpg" Stretch="UniformToFill"/>
    </Grid.Background>


    <TabControl Background="Transparent" Margin="8">
      <!-- TASK 1 -->
      <TabItem Header="{Binding Source={StaticResource wLoc}, Path=R.Task1}" >
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="35*" />
            <ColumnDefinition Width="65*" />
          </Grid.ColumnDefinitions>
          <StackPanel Orientation="Horizontal">
            <ComboBox DataContext="{Binding Siblings.Filter}" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedFilter}"
                   VerticalContentAlignment="Center"  MinWidth="100" Margin="8"/>
            <Button Content="{Binding Source={StaticResource wLoc}, Path=R.AvgHeight}" Command="{Binding AvgHeightCommand}" Margin="8" Padding="8" />
          </StackPanel>
          <my:ucPatientsView DataContext="{Binding Patients}" Grid.Row="1"  />
          <my:ucPatientDetail DataContext="{Binding Siblings}" Grid.Row="1" Grid.Column="1" />
       
        </Grid>
      </TabItem>
      <!-- SEARCH -->
      <TabItem Header="{Binding Source={StaticResource wLoc}, Path=R.Search}" >
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
          </Grid.RowDefinitions>
          <StackPanel Orientation="Horizontal">
            <TextBox Text="{Binding FilterText,UpdateSourceTrigger=PropertyChanged}" 
                       VerticalContentAlignment="Center" Margin="8" MinWidth="100" KeyDown="TextBox_KeyDown"/>
            <ComboBox DataContext="{Binding FilteredPatients.Filter}" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedFilter}"
                       VerticalContentAlignment="Center"  MinWidth="100" Margin="8"/>
            <Button Content="{Binding Source={StaticResource wLoc}, Path=R.Search}" Command="{Binding SearchCommand}" Margin="8" Padding="8" />
            <Label  DataContext="{Binding FilteredPatients}"
                    VerticalContentAlignment="Center" Content="{Binding Count}" Foreground="White" />
           </StackPanel>
          <my:ucPatientsTable DataContext="{Binding FilteredPatients}" Grid.Row="1" IsReadonOnlyGrid="True" />
        </Grid>

      </TabItem>
      <!-- EDIT -->
      <TabItem Header="{Binding Source={StaticResource wLoc}, Path=R.Edit}">
        <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <StackPanel Orientation="Horizontal">
      <Button Content="{Binding Source={StaticResource wLoc}, Path=R.Insert}" Command="{Binding InsertCommand}" Margin="8" Padding="8" />
      <Button Content="{Binding Source={StaticResource wLoc}, Path=R.Delete}" Command="{Binding DeleteCommand}" Margin="8" Padding="8" />
      <Button Content="{Binding Source={StaticResource wLoc}, Path=R.Save}" Command="{Binding SaveCommand}" Margin="8" Padding="8" />
    </StackPanel>
    <my:ucPatientsTable DataContext="{Binding Patients}" Grid.Row="1" />
        </Grid>
      </TabItem>
    
    
    
  </TabControl>
  </Grid>
  
</Window>
